﻿<!-- _meta 作为公共模版分离出去 -->
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<link rel="Shortcut Icon" href="/admin/imgs/logo.ico"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css"/>
	<title>大会后台</title>
	<style type="text/css">
		input[type=file] { padding: 5px; width: 200px; background: #EEE; }
	</style>

	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>
	<script type="text/javascript" src="js/admin.js"></script>
	<script type="text/javascript">
	</script>
</head>
<body>
<section class="Hui-article-box" style="position:relative;top:0;left:0;">
	<nav class="breadcrumb" style="color:#888;">
		<i class="Hui-iconfont">&#xe67f;</i>
		<a href="main.html" class="maincolor">首页</a>
		<span class="c-gray en">&gt;</span>
		前台
		<span class="c-gray en">&gt;</span>
		大会资料
		<span class="c-gray en">&gt;</span>
		新增
	</nav>
</section>
<div class="page-container" id="upload" style="margin:10px 10%;width:50%;position:relative;top:50px;left:0;">
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			资料上传：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<form action="/api/admin/meet/file/upload" method="post" enctype="multipart/form-data">
				<input type="file" name="file">
				<button class="btn btn-secondary radius" type="submit">立即上传</button>
			</form>
		</div>
	</div>
</div>
<div class="page-container" id="txt" style="margin:10px 10%;width:50%;position:relative;top:50px;left:0;">
	<input type="hidden" id="id">
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			大会选择：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<select class="input-text" id="meet">
				<option value="0">-选择大会-</option>
			</select>
		</div>
	</div>
	<div class="row cl" style="margin-bottom:20px;">
		<label class="form-label col-xs-4 col-sm-3">
			文件名：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" placeholder="文件名" id="fname">
		</div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
			<button onClick="save()" class="btn btn-secondary radius" type="button">立即上传</button>
			<button onClick="back()" class="btn btn-default radius" type="button"> &nbsp; 取消 &nbsp; </button>
		</div>
	</div>
</div>

<span id="pop"></span>
</body>
</html>


<script type="text/javascript">
	var fid = getParamByUrl('fid');
	(function(){
		if (fid=='')  {
			$('#upload').show();
			$('#txt').hide();
		} else {
			$('#id')[0].value = fid;
			$('#upload').hide();
			$('#txt').show();
		}
		getMeet();
	})();
	//获取大会
	function getMeet(){
		$.ajax({
			type: 'post',
			url: domain+'meet/option',
			data: {},
			success: function (res) {
				res = JSON.parse(res);
				console.log(res);
				if (res.code!=0) {
					pop({msg:res.msg}); return
				}
				var d = res.data;
				var h = '', i;
				h += '<option value="0">选择大会</option>';
				for (i=0; i<d.length; i++) {
					if (d[i].checked=='Y') {
						h += '<option value="'+d[i].id+'" selected>';
					} else {
						h += '<option value="'+d[i].id+'">';
					}
					h += d[i].title;
					h += '</option>';
				}
				$('#meet').html(h);
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
	//保存
	function save(){
		var id = $('#id').val();
		var meet = $('#meet').val();
		var fname = $('#fname').val();
		if (!id) { pop({msg:'没有上传'}); return }
		if (meet==0) { pop({msg:'没有选择大会'}); return }
		if (fname=='') { pop({msg:'没有填写文件名'}); return }
		var formData = {
			id: id, meetid: meet, fname: fname,
		};
		$.ajax({
			type: 'post',
			url: domain+'meet/file/add',
			data: formData,
			success: function (res) {
				res = JSON.parse(res);
				console.log(res);
				if (res.code!=0) {
					pop({msg:res.msg}); return;
				}
				pop({msg:'成功'});
				setTimeout(function(){
					window.location.href = 'meFile.html';
				},1000);
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
	function back(){
		window.location.href = 'video.html';
	}
</script>